//1:appid 2:project 3:privatekey
const args = process.argv.slice(2);
const ciPath = '/Users/root/Library/miniprogram-ci/node_modules/miniprogram-ci'
const ci = require(ciPath)
  ; (async () => {
    const project = new ci.Project({
      appid: args[0],
      type: 'miniGame',
      projectPath: args[1],
      privateKeyPath: args[2],
      ignores: ['node_modules/**/*'],
    })
    const previewResult = await ci.preview({
      project,
      desc: 'ci-preview', // 此备注将显示在“小程序助手”开发版列表中
      setting: {
        es6: true,
      },
      qrcodeFormat: 'image',
      qrcodeOutputDest: 'qrcode.jpg',
      onProgressUpdate: console.log,
      // pagePath: 'pages/index/index', // 预览页面
      // searchQuery: 'a=1&b=2',  // 预览参数 [注意!]这里的`&`字符在命令行中应写成转义字符`\&`
    })
    console.log(previewResult)
    process.exit()
  })()